﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BBPA.Admin.SYS.Orders.Call4Delivery
{
    public partial class List : ListPage
    {
        BLL.Supplier bllList = new BLL.Supplier();
        BLL.Supplier bll = new BLL.Supplier();
        //
        //string sql_orders_goods = " WaitSupplierCheckNum>0  and OrdersID in(select id from V_Orders where State=" + (int)EnumHelper.OrdersState.GetMoney + "  and FirstExpectBuyDate is not null and datediff(day,FirstExpectBuyDate,getdate())=-1 )";
        //string sql_orders_goods_WaitCall4Delivery = " WaitSupplierCheckNum>0 and HasCall4Delivery=0 and OrdersID in(select id from V_Orders where State=" + (int)EnumHelper.OrdersState.GetMoney + "  and FirstExpectBuyDate is not null and datediff(day,FirstExpectBuyDate,getdate())=-1 )";
        //string sql_orders_goods_hasCall4Delivery = " WaitSupplierCheckNum>0 and HasCall4Delivery=1 and OrdersID in(select id from V_Orders where State=" + (int)EnumHelper.OrdersState.GetMoney + "  and FirstExpectBuyDate is not null and datediff(day,FirstExpectBuyDate,getdate())=-1 )";
        
        string sql_orders_goods = " WaitSupplierCheckNum>0  and OrdersID in(select id from V_Orders where State>=" + (int)EnumHelper.OrdersState.GetMoney + " and  State<=" + (int)EnumHelper.OrdersState.Buying + " )";
        string sql_orders_goods_WaitCall4Delivery = " WaitSupplierCheckNum>0 and HasCall4Delivery=0 and OrdersID in(select id from V_Orders where State>=" + (int)EnumHelper.OrdersState.GetMoney + "  and  State<=" + (int)EnumHelper.OrdersState.Buying + " )";
        string sql_orders_goods_hasCall4Delivery = " WaitSupplierCheckNum>0 and HasCall4Delivery=1 and OrdersID in(select id from V_Orders where State>=" + (int)EnumHelper.OrdersState.GetMoney + "  and  State<=" + (int)EnumHelper.OrdersState.Buying + "  )";
        
        //
        BLL.V_Orders_Goods bllV_Orders_Goods = new BLL.V_Orders_Goods();
        //
        BLL.Orders_Goods bllOrders_Goods = new BLL.Orders_Goods();
        BLL.Goods bllGoods = new BLL.Goods();
        BLL.Orders_State_Log bllOrders_State_Log = new BLL.Orders_State_Log();
        BLL.Supplier bllSupplier = new BLL.Supplier();
        BLL.Account_Change_Log bllAccount_Change_Log = new BLL.Account_Change_Log();
        protected void Page_Load(object sender, EventArgs e)
        {
            //
            Master.show_btn_add = Master.show_btn_bat_del = Master.show_info = Master.show_edit =Master.show_checkbox= false;
            Master.show_listControls = true;
            //
            Master.BasicSQL = "id in (select SupplierID from V_Orders_Goods where " + sql_orders_goods + ") and IsDelivery=1";
        }
        public override void buildSQL_Page_List_search() { }
        public override DataSet get_Page_DataSet(string sql_, string orderby_, int pageFrom_, int pageTo_) { return bllList.GetListByPage(sql_, orderby_, pageFrom_, pageTo_); }
        /// <summary>
        /// 获取本供货商，还有多少种货未通知
        /// </summary>
        /// <param name="SupplierID_"></param>
        /// <returns></returns>
        protected int HasNoCall4Delivery_GoodsCount(object SupplierID_)
        {
            return bllV_Orders_Goods.GetRecordCount(sql_orders_goods_WaitCall4Delivery+" and SupplierID="+SupplierID_);
        }
        /// <summary>
        /// 获取本供货商，已通知送货种数
        /// </summary>
        /// <param name="SupplierID_"></param>
        /// <returns></returns>
        protected int HasCall4Delivery_GoodsCount(object SupplierID_)
        {
            return bllV_Orders_Goods.GetRecordCount(sql_orders_goods_hasCall4Delivery);
        }
    }
}